package com.haoshuang.zhouzhoubang.ui.page.mine.invite.create

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class CreateTeamMemberViewModel : BaseViewModel() {

    /**
     * 邀请不存在的账号
     */
    val inviteTeamMemberData = StatefulMutableLiveData<Any>()
    fun inviteTeamMember(phones: String, first_level_ids: String, second_level_ids: String, little_ids: String) = netRequest {
        start { inviteTeamMemberData.value = StateData.Loading }
        request { ApiRepo.inviteTeamMember(phones, first_level_ids, second_level_ids, little_ids)  }
        success { inviteTeamMemberData.value = StateData.Success(it.data) }
        error { code, msg ->
            inviteTeamMemberData.value = StateData.Error(code, msg)
        }
    }

}